package com.demo.controller;
import java.util.ArrayList;
import java.util.List;

/**
 * 返回结果对象
 * Created by Scott on 2017/1/17.
 */
public class JSONResult<E> {

    public JSONResult(){};

    public JSONResult(String message){
        this.message = message;
    }

    public JSONResult(boolean success, String code, String message){
        this.success=success;
        this.code = code;
        this.message=message;
    }

    public JSONResult(boolean success, String code, String message, E e){
        this.success=success;
        this.code = code;
        this.message=message;
        this.data = e;
    }
    public JSONResult(boolean success, String code, String message, List<E> listE, E e){
        this.success=success;
        this.code = code;
        this.message=message;
        this.rows = listE;
        this.data = e;
    }
    public JSONResult(boolean success, String code, String message, List<E> e){
        this.success=success;
        this.code = code;
        this.message=message;
        this.rows = e;
    }

    public JSONResult(String code, boolean success, String message, long page, long total, List<E> rows) {
        this.code = code;
        this.success = success;
        this.message = message;
        this.page = page;
        this.total = total;
        this.rows = rows;
    }

    public JSONResult(boolean success, String code, String message, long page, long total, E data, String url, List<E> rows) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.page = page;
        this.total = total;
        this.data = data;
        this.url = url;
        this.rows = rows;
    }

    /**
     * 操作结果状态,默认为true
     */
    private boolean success = true;

    /**
     * 结果编码，200表示成功
     */
    private String code;

    /**
     * 操作提示
     */
    private String  message = "操作成功";

    /**
     * 页码
     */
    private long page;

    /**
     * 记录总数
     */
    private long total;

    /**
     * 结果对象
     */
    private E data =null;
    /**
     * 文件地址url
     */
    private String  url =null;

    private List<E> rows = new ArrayList<E>();

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    public List<E> getRows() {
        return rows;
    }

    public void setRows(List<E> rows) {
        this.rows = rows;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public long getPage() {
        return page;
    }

    public void setPage(long page) {
        this.page = page;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }
}